package cloudnative.demo.labclient.controller;

import cloudnative.demo.labclient.client.LabServiceClient;
import cloudnative.demo.labclient.model.Laboratory;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@AllArgsConstructor
@RestController
@Slf4j
@RequestMapping("/laboratory")
public class LabServiceClientController {

    @Autowired
    private LabServiceClient labServiceClient;


    // 查询所有实验室信息
    @GetMapping("/queryAll")
    public List<Laboratory> queryAllLaboratories() {
        return labServiceClient.queryAllLaboratories();
    }

    // 通过WorkerID查询实验室信息
    @PostMapping("/queryML")
    public List<Laboratory> queryLaboratoriesByWorkerID(@RequestBody Laboratory laboratory) {
        return labServiceClient.queryLaboratoriesByWorkerID(laboratory);
    }

    // 添加实验室
    @PostMapping("/addL")
    public void addLaboratory(@RequestBody Laboratory laboratory) {
        labServiceClient.addLaboratory(laboratory);
    }

    // 删除实验室
    @PostMapping("/deleteL")
    public void deleteLaboratory(@RequestBody Laboratory laboratory) {
        labServiceClient.deleteLaboratory(laboratory);
    }

    // 更新实验室信息
    @PostMapping("/alterL")
    public void updateLaboratory(@RequestBody Laboratory laboratory) {
        labServiceClient.updateLaboratory(laboratory);
    }
}
